use Tk;
use utf8;

my $mw = MainWindow->new(-title => "事件处理示例");



# 按下任意键弹窗提示
$mw->bind("<KeyPress>", sub {
    my $event = shift;
    my $keysym;
    eval {
        $keysym = $event->keysym;
    };
    if ($@) {
        $keysym = "未知按键 (错误: $@)";
    }
    print "您按下了: $keysym\n";
    $mw->messageBox(-message => "您按下了: $keysym");
});

MainLoop;